package com.zj.data;

import org.apache.commons.lang.StringUtils;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

public class DataCenter {

    private static ConcurrentMap<String, Object> dataMap = new ConcurrentHashMap<>();

    public static void saveData(String key, Object object) {
        if (StringUtils.isEmpty(key)) {
            return;
        }
        dataMap.put(key, object);
    }

    public static <T> T getData(String key, Class<T> c) {
        if (StringUtils.isEmpty(key)) {
            return null;
        }
        if (dataMap.containsKey(key)) {
            return (T) dataMap.get(key);
        }
        return null;
    }
}
